import request from "../utils/request.js"

// 登录方法
export function login(params) {
	return request({
		url: "/wxLogin",
		method: "post",
		data: params,
	});
}

//根据小区id获取站点
export function getCommunityById(params) {
	return request({
		url: `/wx/getCommunityById`,
		method: 'get',
		data:params
	})
}
//根据小区名称获取列表
export function getCommunityByName(params) {
	return request({
		url: `/wx/getCommunityByName`,
		method: 'get',
		data: params
	})
}



//获取用户信息
export function getUserInfo(params) {
	return request({
		url: `/user/wxUser/getUserInfo/${params.id}`,
		method: 'get',
	})
}
//获取用户信息
export function editUser(params) {
	return request({
		url: `/user/wxUser/editUser`,
		method: 'put',
		data: params
	})
}


//根据名字搜索小区
export function selectCommunity(params) {
	return request({
		url: `/user/community/getCommunityList`,
		method: 'get',
		data: params
	})
}

//根据用户查询收货地址
export function getAddress(params) {
	return request({
		url: `/user/addressBook/list`,
		method: 'get',
		data: params
	})
}

//根据地址id查询收货地址详情
export function getById(params) {
	return request({
		url: `/user/addressBook/${params.id}`,
		method: 'get',
	})
}

//新增/修改 收货地址
export function configAddress(params) {
	return request({
		url: `/user/addressBook/configAddress`,
		method: 'post',
		data: params
	})
}
//删除收货地址
export function delAddress(params) {
	return request({
		url: `/user/addressBook/delAddress/${params.id}`,
		method: 'delete',
	})
}
//根据地址id修改收货地址详情
export function editAddress(params) {
	return request({
		url: `/user/addressBook`,
		method: 'put',
		data: params
	})
}

//设置默认地址
export function setDefaultAddress(params) {
	return request({
		url: `/user/addressBook/default`,
		method: 'put',
		data: params
	})
}
//下单
export function saveOrder(params) {
	return request({
		url: `/user/order/submit`,
		method: 'post',
		data: params
	})
}

//查询订单列表
export function getOrderPage(params) {
	return request({
		url: `/user/order/getOrderPage`,
		method: 'get',
		data: params
	})
}

//查询订单详情
export function getOrderDetail(params) {
	return request({
		url: `/user/order/getOrderDetail/${params.id}`,
		method: 'get',
	})
}

//取消订单
export function cancelOrder(params) {
	return request({
		url: `/user/order/cancelOrder/${params.id}`,
		method: 'delete',
	})
}

//工作者获取订单
export function getWorkOrder(params) {
	return request({
		url: `/user/work/getWorkOrder`,
		method: 'get',
		data: params
	})
}
//抢单
export function placeOrder(id) {
	return request({
		url: `/user/work/placeOrder/${id}`,
		method: 'put'
	})
}
//送达
export function arrivedOrder(id) {
	return request({
		url: `/user/work/arrivedOrder/${id}`,
		method: 'put'
	})
}
//上传文件到 OSS
export function uploadFile() {
	return request({
		url: `/user/ossApi/uploadFile`,
		method: 'get'
	})
}
